/*
 * =====================================================================================
 *
 *       Filename:  cl_poll_poller.hxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  04/08/2011 03:24:08 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ken), chen_kenz@emc.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#ifndef _CL_POLL_POLLER_HXX_
#define _CL_POLL_POLLER_HXX_

#include <vector>
#include <map>
#include "cl_poller.hxx"

namespace neo
{
class CLPollPoller: public CLPoller
{
public:
  ~CLPollPoller();


private:
	typedef std::vector<struct pollfd> EventVector;
	typedef std::map<int, CLChannel*> ChannelMap;

private:
  virtual bool doPoll(long millisecs, CLChannelList& chs);
	virtual bool doAdd(CLChannel* ch);
	virtual bool doRemove(CLChannel* ch);
	virtual bool doModify(CLChannel* ch);
  void fillReadyChannels(int readyEvents, CLChannelList& chs);
  bool findEventfd(int pfd, EventVector::iterator& itr);

private:
	ChannelMap m_channels;
	EventVector m_events; 
};
} // neo

#endif //_CL_POLL_POLLER_HXX_

